package com.leetcode.根据数据结构分类.数组;

/**
 * @author: xiaomi
 * @date: 2021/3/27
 * @description:    1480. 一维数组的动态和
 * https://leetcode-cn.com/problems/running-sum-of-1d-array/
 */
public class A_1480_一维数组的动态和 {

    public static void main(String[] args) {

    }

    /**
     * 其实就是前缀和
     * @param nums
     * @return
     */
    public int[] runningSum(int[] nums) {
        int len = nums.length;
        int[] res = new int[len];
        res[0] = nums[0];
        for (int i = 1; i < len; i++) {
            res[i] = res[i - 1] + nums[i];
        }
        return res;
    }

}
